#!/home/dechao_meng/anaconda3/bin/python
import time
import sys
import os
from selenium import webdriver
import pyperclip

recent_value = ""
chrome = webdriver.Chrome()
chrome.get("https://translate.google.com")
input_area = chrome.find_element_by_id('source')
while True:
    tmp_value = pyperclip.paste()
    
    if tmp_value != recent_value:
        recent_value = tmp_value
        print("Value changed: %s" % str(recent_value)[:20])
        tmp_value = tmp_value.replace('\n', ' ')
        input_area.clear()
        input_area.send_keys(tmp_value)
    time.sleep(0.1)